package com.itany.corejava.code06_面向对象.bms;

/**
 * @author 石小俊
 * @date 2024年02月26日 8:48
 */
public abstract class Account {

    //设置为静态变量，将变量所属交给类，所有对象共享该变量
    private static int currentId=1000;
    private int id;
    private String name;
    private String password;
    private String personId;
    private String phone;
    private double balance;

    public Account() {
        this.id=currentId++;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getPersonId() {
        return personId;
    }

    public void setPersonId(String personId) {
        this.personId = personId;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    /**
     * 存款方法，该方法不允许子类重写，使用final修饰
     * @param money
     */
    public final void deposit(double money){
        this.balance+=money;
    }

    /**
     * 取款方法，不同的子类实现方式不同，子类必须重写，因此定义为抽象方法
     * @param money
     * @return
     */
    public abstract boolean withdrawMoney(double money);
}
